package team.stride.database.crud.playlists;

import java.util.List;

import team.stride.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class PlaylistsAdapter extends BaseAdapter
{
	private Context context;
	private List<PlaylistsItem> playlistsList;

	public PlaylistsAdapter(Context context, List<PlaylistsItem> mapslist)
	{
		this.context = context;
		this.playlistsList = mapslist;
	}

	public int getCount()
	{
		return playlistsList.size();
	}

	public PlaylistsItem getItem(int position)
	{
		return playlistsList.get(position);
	}

	public long getItemId(int position)
	{
		return position;
	}

	public View getView(final int position, View convertView, ViewGroup viewGroup)
	{
		PlaylistsItem entry = playlistsList.get(position);
		if (convertView == null)
		{
			LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView = inflater.inflate(R.layout.bd_playlists_row, null);
		}
		
		TextView playlistsName = (TextView) convertView.findViewById(R.id.playlistsName);
		playlistsName.setText(entry.getName());


		TextView playlistsDetails = (TextView) convertView.findViewById(R.id.playlistsDetails);
		playlistsDetails.setText("" + entry.getDetails());

		return convertView;
	}
}
